package org.boot.controller;

import jakarta.annotation.Resource;
import org.boot.service.AccountService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Resource
    AccountService accountService;

    // http://localhost:9090/account/pay
    @RequestMapping("/pay")
    String pay() {
        accountService.updatePayment(1L, BigDecimal.valueOf(100.0));
        return "1";
    }

    @RequestMapping("/pay2")
    String pay2() {
        accountService.updatePaymentWithDbLock(2L, BigDecimal.valueOf(100.0));
        return "2";
    }
}
